/**
 * @filename:CustomBbRoleGroupBindController 2022-2-23 16:59:31
 * @project multi-modules-project  V1.0
 * Copyright(c) 2018 yuanz Co. Ltd.
 * All right reserved.
 */
package com.yz.aiks.multimodules.controller;

import com.github.pagehelper.PageInfo;
import com.yz.aiks.multimodules.entity.CustomBbRoleGroupBind;
import com.yz.aiks.multimodules.service.CustomBbRoleGroupBindService;
import com.yz.base.boot.entity.AppPage;
import com.yz.base.boot.entity.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * custom_bb_role_group_bind接口层.
 *
 * @author <a href="mailto:aiks_yuan@163.com">yuanz</a>
 * @date 2022-2-23 16:59:31
 * @since V1.0
 **/
@Api(description = "custom_bb_role_group_bind",value="custom_bb_role_group_bind" )
@RestController
@RequestMapping("/customBbRoleGroupBind")
public class CustomBbRoleGroupBindController {

	Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	public CustomBbRoleGroupBindService customBbRoleGroupBindServiceImpl;

	/**
	 * 查询custom_bb_role_group_bind对象  <swagger GET请求>.
	 *
	 * @param   id
	 * @return  customBbRoleGroupBind
	 */
	@GetMapping("/getCustomBbRoleGroupBindById/{id}")
	@ApiOperation(value = "获取custom_bb_role_group_bind信息", notes = "获取custom_bb_role_group_bind信息[customBbRoleGroupBind]，作者：yuanz")
	@ApiImplicitParam(paramType="path", name = "id", value = "custom_bb_role_group_bindid", required = true, dataType = "Long")
	public JsonResult<CustomBbRoleGroupBind> getCustomBbRoleGroupBindById(@PathVariable("id")Long id){
		JsonResult<CustomBbRoleGroupBind> result = new JsonResult<CustomBbRoleGroupBind>();
		try {
			CustomBbRoleGroupBind customBbRoleGroupBind = customBbRoleGroupBindServiceImpl.selectByPrimaryKey(id);
			if (customBbRoleGroupBind != null) {
				result.setCode(1);
				result.setMessage("成功");
				result.setData(customBbRoleGroupBind);
			} else {
				logger.error("获取custom_bb_role_group_bind失败ID："+id);
				result.setCode(-1);
				result.setMessage("你获取的custom_bb_role_group_bind不存在");
			}
		} catch (Exception e) {
			logger.error("获取custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}

	/**
	 * 添加custom_bb_role_group_bind对象.
	 *
	 * @param   customBbRoleGroupBind
	 * @return  int
	 */
	@PostMapping("/insertSelective")
	@ApiOperation(value = "添加custom_bb_role_group_bind", notes = "添加custom_bb_role_group_bind[customBbRoleGroupBind],作者：yuanz")
	public JsonResult<CustomBbRoleGroupBind> insertSelective(@RequestBody CustomBbRoleGroupBind customBbRoleGroupBind){
		JsonResult<CustomBbRoleGroupBind> result = new JsonResult<CustomBbRoleGroupBind>();
		try {
			int rg = customBbRoleGroupBindServiceImpl.insertSelective(customBbRoleGroupBind);
			if (rg > 0) {
				result.setCode(1);
				result.setMessage("成功");
				result.setData(customBbRoleGroupBind);
			} else {
				logger.error("添加custom_bb_role_group_bind执行失败："+customBbRoleGroupBind.toString());
				result.setCode(-1);
				result.setMessage("执行失败，请稍后重试");
			}
		} catch (Exception e) {
			logger.error("添加custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}

	/**
	 * 删除custom_bb_role_group_bind对象.
	 *
	 * @param   id
	 * @return  int
	 */
	@PostMapping("/deleteByPrimaryKey")
	@ApiOperation(value = "删除custom_bb_role_group_bind", notes = "删除custom_bb_role_group_bind,作者：yuanz")
	@ApiImplicitParam(paramType="query", name = "id", value = "custom_bb_role_group_bindid", required = true, dataType = "Long")
	public JsonResult<Object> deleteByPrimaryKey(Long id){
		JsonResult<Object> result = new JsonResult<Object>();
		try {
			int reg = customBbRoleGroupBindServiceImpl.deleteByPrimaryKey(id);
			if (reg > 0) {
				result.setCode(1);
				result.setMessage("成功");
				result.setData(id);
			} else {
				logger.error("删除custom_bb_role_group_bind失败ID："+id);
				result.setCode(-1);
				result.setMessage("执行错误，请稍后重试");
			}
		} catch (Exception e) {
			logger.error("删除custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}

	/**
	 * 修改custom_bb_role_group_bind对象.
	 *
	 * @param   customBbRoleGroupBind
	 * @return  customBbRoleGroupBind
	 */
	@ApiOperation(value = "修改custom_bb_role_group_bind", notes = "修改custom_bb_role_group_bind[customBbRoleGroupBind],作者：yuanz")
	@PostMapping("/updateByPrimaryKeySelective")
	public JsonResult<CustomBbRoleGroupBind> updateByPrimaryKeySelective(@RequestBody CustomBbRoleGroupBind customBbRoleGroupBind){
		JsonResult<CustomBbRoleGroupBind> result = new JsonResult<CustomBbRoleGroupBind>();
		try {
			int reg = customBbRoleGroupBindServiceImpl.updateByPrimaryKeySelective(customBbRoleGroupBind);
			if (reg > 0) {
				result.setCode(1);
				result.setMessage("成功");
				result.setData(customBbRoleGroupBind);
			} else {
				logger.error("修改custom_bb_role_group_bind失败ID："+customBbRoleGroupBind.toString());
				result.setCode(-1);
				result.setMessage("执行错误，请稍后重试");
			}
		} catch (Exception e) {
			logger.error("修改custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}

	/**
	 * 获取匹配custom_bb_role_group_bind.
	 *
	 * @param   customBbRoleGroupBind
	 * @return  List<CustomBbRoleGroupBind>
	 */
	@ApiOperation(value = "条件查询custom_bb_role_group_bind", notes = "条件查询[customBbRoleGroupBind],作者：yuanz")
	@PostMapping("/queryCustomBbRoleGroupBindList")
	public JsonResult<List<CustomBbRoleGroupBind>> queryCustomBbRoleGroupBindList(@RequestBody CustomBbRoleGroupBind customBbRoleGroupBind){
		JsonResult<List<CustomBbRoleGroupBind>> result = new JsonResult<List<CustomBbRoleGroupBind>>();
		try {
			List<CustomBbRoleGroupBind> list = customBbRoleGroupBindServiceImpl.queryCustomBbRoleGroupBindList(customBbRoleGroupBind);
			result.setCode(1);
			result.setMessage("成功");
			result.setData(list);
		} catch (Exception e) {
			logger.error("获取custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}

	/**
	 * 分页条件查询custom_bb_role_group_bind.
	 *
	 * @param   pageNum
	 * @param   pageSize
	 * @return  PageInfo<CustomBbRoleGroupBind>
	 */
	@GetMapping("/getPageCustomBbRoleGroupBind")
	@ApiOperation(value = "分页查询", notes = "分页查询返回对象[PageInfo<CustomBbRoleGroupBind>],作者：yuanz")
	@ApiImplicitParams({
        @ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"),
        @ApiImplicitParam(paramType="query", name = "pageSize", value = "页行数", required = true, dataType = "int")
    })
	public JsonResult<PageInfo<CustomBbRoleGroupBind>> getCustomBbRoleGroupBindBySearch(Integer pageNum,Integer pageSize){
		JsonResult<PageInfo<CustomBbRoleGroupBind>> result = new JsonResult<PageInfo<CustomBbRoleGroupBind>>();
		AppPage<CustomBbRoleGroupBind> page = new AppPage<CustomBbRoleGroupBind>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		//其他参数
		CustomBbRoleGroupBind customBbRoleGroupBind = new CustomBbRoleGroupBind();
		page.setParam(customBbRoleGroupBind);
		//分页数据
		try {
			PageInfo<CustomBbRoleGroupBind> pageInfo = customBbRoleGroupBindServiceImpl.getCustomBbRoleGroupBindBySearch(page);
			result.setCode(1);
			result.setMessage("成功");
			result.setData(pageInfo);
		} catch (Exception e) {
			logger.error("分页查询custom_bb_role_group_bind执行异常："+e.getMessage());
			result.setCode(-1);
			result.setMessage("执行异常，请稍后重试");
		}
		return result;
	}
}
